package commands

import (
	"context"
	"errors"
	"fmt"
	"os"

	cli "github.com/urfave/cli/v3"
)

var (
	ErrNoImageProvided     = errors.New("image must be provided")
	ErrNoContainerProvided = errors.New("container must be provided")
)

func commandNotFoundHandler(ctx context.Context, cmd *cli.Command, s string) {
	fmt.Fprintf(cmd.ErrWriter, "%q: %q is not a %s command.\n", cmd.FullName(), s, cmd.Name)
	cli.ShowSubcommandHelp(cmd)
	os.Exit(1)
}

func exitErrHandler(ctx context.Context, cmd *cli.Command, err error) {
	if err != nil {
		fmt.Fprintf(cmd.ErrWriter, "%q: %s\n", cmd.FullName(), err)
		os.Exit(1)
	}
}
